package server.game.entity;

import server.game.entity.character.player.Player;

public class GroundItem extends Entity {

	private int timer = 50;
	private boolean isPublic;
	private int x, y, z, id, amount;
	private Player owner = null;

	public GroundItem(Player owner, int id, int amount, int x, int y, int z) {
		if(owner != null) {
			isPublic = false;
			this.owner = owner;
		}
		this.id = id;
		this.amount = amount;
		this.x = x;
		this.y = y;
		this.z = z;
	}

	public GroundItem(int id, int amount, int x, int y, int z) {
		isPublic = true;
		this.id = id;
		this.amount = amount;
		this.x = x;
		this.y = y;
		this.z = z;
	}

	public void put(Player p) {
		if(p == null) return;
		//TODO send ground item to client
	}

	public void delete(Player p) {
		if(p == null) return;
		//TODO remove ground item from client
	}

	public boolean canAccess(Player p) {
		if(isPublic) {
			return true;
		} else if(owner != null && owner == p) {
			return true;
		}
		return false;
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public int getTimer() {
		return timer;
	}

	public void setTimer(int timer) {
		this.timer = timer;
	}

	public void decrementTimer() {
		timer--;
	}

	public int getX() {
		return x;
	}	

	public int getY() {
		return y;
	}

	public int getZ() {
		return z;
	}

	public int getAmount() {
		return amount;
	}

	public void setAmount(int amount) {
		this.amount = amount;
	}

	public boolean isPublic() {
		return isPublic;
	}

	public void setPublic(boolean isPublic) {
		this.isPublic = isPublic;
	}

	public void setOwner(Player owner) {
		this.owner = owner;
	}

	public Player getOwner() {
		return owner;
	}
}
